/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.proyectoGonseca.entities;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

@Entity
@Table(name = "materias", catalog = "gonseca", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Materias.findAll", query = "SELECT c FROM Materias c"),
    @NamedQuery(name = "Materias.findByid_materias", query = "SELECT c FROM Materias c WHERE c.id_materias = :id_materias"),
    @NamedQuery(name = "Materias.findBynombre", query = "SELECT c FROM Materias c WHERE c.nombre = :nombre")})

public class Materias implements Serializable {
    private static final long serialVersionUID = 1L;

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "id_materias")
    private Integer id_materias;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 150)
    @Column(name = "nombre")
    private String nombre;
    
   @ManyToOne(optional = false)
    private Universidades universidades;
   
   @OneToMany(cascade = CascadeType.ALL, mappedBy = "materias")
    private List<Parciales> parcialesList;
    
   @ManyToMany 
    @JoinTable(name="Mate_Prof", 
          joinColumns=@JoinColumn(name="id_materias"),
          inverseJoinColumns=@JoinColumn(name="id_profesores"))
    private Collection<Profesores> profesores;
   
    public Materias() {
    }

    public Materias(Integer id_materias, String nombre) {
        this.id_materias = id_materias;
        this.nombre = nombre;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id_materias != null ? id_materias.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Materias)) {
            return false;
        }
        Materias other = (Materias) object;
        if ((this.id_materias == null && other.id_materias != null) || (this.id_materias != null && !this.id_materias.equals(other.id_materias))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.proyectoGonseca.entities.Materias[ id_materias=" + id_materias + " ]";
    }

    public Integer getId_materias() {
        return id_materias;
    }

    public void setId_materias(Integer id_materias) {
        this.id_materias = id_materias;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    

    
}